package com.test.wog.controller;

import com.test.wog.service.NodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author: LX
 * @createDate: 2020-01-26
 * @desc: 关键节点的Controller
 */
@RestController
public class NodeController {
    @Autowired
    private NodeService ns;

    @RequestMapping("/getNodeByName")
    @ResponseBody
    public String getNodeByName(
            @RequestParam(value = "name",required = true) String name
    ){
        return ns.getNodeByName(name);
    }

    @RequestMapping("/getNodeByType")
    @ResponseBody
    public String getNodeByType(
            @RequestParam(value = "type",required = true) String type
    ){
        return ns.getNodeByType(type);
    }

    @RequestMapping("/getNodeByLoc")
    @ResponseBody
    public String getNodeByLoc(
            @RequestParam(value = "lon",required = true) double lon,
            @RequestParam(value = "lat",required = true) double lat
    ){
        return ns.getNodeByLoc(lon, lat);
    }

    @RequestMapping("/init")
    @ResponseBody
    public int getNodeByLoc(
    ){
        return ns.insertNode();
    }

//    @RequestMapping("/getNode")
//    @ResponseBody
//    public String getNodeByID(
//            @RequestParam(value = "id",required = true) int id
//    ){
//        return ns.getNodeByID(id);
//    }
}
